Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make upgradable #3

Merged
merged 4 commits into from
Jun 14, 2023
Merged

Make upgradable #3

merged 4 commits into from
Jun 14, 2023

Conversation

yu23ki14
Copy link
Collaborator

@yu23ki14 yu23ki14 commented Jun 7, 2023

やったこと

  • OpenzeppelinのERC1155Upgradableに変更
  • upgradableのテストコード記述
  • HENKAKU Tokenの名前を汎用的にするために、CommunityTokenに変更
  • solidityのバージョンを0.8.17に、0.8.20にしたほうがいいかも

#1

@yu23ki14 yu23ki14 requested a review from yawn-c111 June 7, 2023 14:17
Copy link
Collaborator

@yawn-c111 yawn-c111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

細かいところばかりですみません!
コメント書かせていただきました 🙏

mapping(address => bool) private _admins;

constructor() {
function initializeAdministration() public virtual initializer {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

あいまいな記憶で申し訳ないのですが、Upgradeableのinitialize系の関数名には、先頭に __ (アンダースコア2つ)をつけるという慣習があったような気がしています。
initializeAdministration() のようなイメージ)
違ったらすみません…

関数修飾子が internal だと安心かもです。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Openzeppelinのドキュメントとかは普通にinitialize()ですね、もし参考になるものがあったら言ってください!
ただ、InteractCommunityToken.solとAdministration.solのinitializeはinternalのほうが良さそうなので、_つけるようにします

communityToken = _communityToken;
}

function transferCommunityToken(uint256 _amount, address _to) internal {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_transferCommunityToken() はいかがでしょうか?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この関数が今使われてないようなので、いったん消しました

require(sent, "Ticket: ERC20 token transfer failed");
}

function batchTransferCommunityToken(uint256 totalPrice, uint256[] memory _amounts, address[] memory _to) internal {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_batchTransferCommunityToken() はいかがでしょうか?

totalPricetotalAmount だと揃ってて分かりやすいかもです。

import "./interfaces/IHenkakuToken.sol";

abstract contract InteractCommunityToken is Administration, MintManager {
address public communityToken;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

address public communityToken; の値をAdminが変更できる関数を追加するのはいかがでしょうか?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

今回のアップデートとは関係のないところで、Ticket.sol の32~34行目について相談させてください!
以前とにかくガス代を下げたかったため私が uint64 を設定したのですが、他コミュニティに使用してもらうことを考えると、念のため3つとも uint256 に戻した方が良いかもと思いました。
いかがでしょうか?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

64でもかなりでかいのでこれで良さそうです

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

こちらも今回のアプデとは関係なく、45~49行目の関数へのコメントは削除するのはいかがでしょうか?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

26~27行目の

mapping(address => uint256[]) private ownerOfRegisteredIds;
mapping(address => uint256[]) private ownerOfMintedIds;

ですが、private のためアンダースコアを追加するのはいかがでしょうか?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

関数内で_つかっている同じ名前の変数があるのでこのままにしておきます

@@ -53,20 +61,19 @@ contract Ticket is ERC1155, ERC1155Supply, Administration, MintManager, Interact

TicketInfo[] private registeredTickets;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private のため _registeredTickets に変更するのはいかがでしょうか?

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "./Administration.sol";
import "./MintManager.sol";
import "./interfaces/IHenkakuToken.sol";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IHenkakuToken.solICommunityToken.sol に変更するのはいかがでしょうか?

Administration,
MintManager,
InteractCommunityToken
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

アップグレーダブルのパターンとしてUUPSを採用するのはいかがでしょうか?
ロジック内に誰がアップグレードできるかを決定する関数( _authorizeUpgrade() )を置くアブストラクトで、そちらを override することで modifier などで簡単にアップグレード権限を設定でき、 _authorizeUpgrade() 自体もアップグレードできるらしいと聞きました!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ちょっと時間が...ww

@yu23ki14 yu23ki14 merged commit 88995e6 into main Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants